<template>
	<view class="main">
		<view style="padding: 20upx 40upx;">
			<topSelectNew @onSearch="onSearch"></topSelectNew>
		</view>
		<!--list-satrt -->
		<view class="list">
			<view class="item" v-for="item in dataList" @click="toAdd(item.id,item.status)">
				<image class="item-img" :src="item.cover"></image>

				<view class="item-right">
					<view class="item-name">
						<view class="item-name-left">
							<span>{{item.userName}}</span>
						</view>

						<view class="item-btn" v-if="item.status==1">通过</view>
						<view class="item-btn item-btn-red" v-if="item.status==2">不通过</view>
						<view class="item-btn item-btn-yellow" v-if="item.status==0">待审核</view>
					</view>
					<view class="item-single">
						<span class="item-single-name">名称</span>
						<span class="item-single-value">{{item.name}}</span>
					</view>
					<view class="item-single">
						<span class="item-single-name">价格</span>
						<span class="item-single-value">¥{{item.money}}</span>
					</view>
					<view class="item-single">
						<span class="item-single-name">申请时间</span>
						<span class="item-single-value"
							v-if="item.createTime">{{item.createTime.substring(0,10)}}</span>
					</view>

				</view>

			</view>
		</view>
		<!--list-end -->


		<view class="list-end" v-if="dataList.length">{{endText}}</view>

		<u-empty v-if="!dataList.length" mode="car" text="暂无数据" icon="/static/empty-img.png">
		</u-empty>

		<!--底部按钮-satrt-->
		<view class="btn">
			<view class="btn-item" @click="toAdd()">
				<view class="btn-plus"><u-icon name="plus" color="#11AA66" size="20"></u-icon></view>
				<span>添加申请</span>
			</view>
		</view>
		<!--底部按钮-end-->

	</view>
</template>

<script>
	import topSelectNew from './topSelect.vue'
	export default {
		components: {
			topSelectNew
		},
		data() {
			return {

				queryParams: {
					status: '',
					pageNum: 1,
					pageSize: 10
				},
				total: 0,
				endText: '',
				dataList: []

			}
		},
		onLoad() {

		},
		onShow() {
			this.queryParams.pageNum = 1
			this.dataList = []
			this.getList()
		},
		methods: {

			onSearch(param) {
				this.queryParams.pageNum = 1
				this.dataList = []
				this.queryParams = {
					...this.queryParams,
					...param
				}
				this.getList()
			},


			getList() {
				this.$modal.msgLoading('加载中')

				var that = this

				this.$postjson('/api/RqComplete/list', this.queryParams).then(res => {
					uni.hideLoading()
					if (res.data.code == 200) {
						let detail = res.data.rows
						detail.forEach(v => {
							let img = v.images ? v.images.split(',') : []
							if (img.length) {
								v.cover = that.baseUrl + img[0]
							}
						})


						if (detail.length < that.queryParams.pageSize) {
							that.endText = '没有更多了'
						}
						that.total = res.data.total
						that.dataList = that.dataList.concat(detail)
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},



			toAdd(id,state) {
				if (!id) {
					uni.navigateTo({
						url: '/pagesMain/production/completed/form'
					})
				} else {
					if(state != 1){
						uni.navigateTo({
							url: '/pagesMain/production/completed/form?id=' + id
						})
					}
					
				}

			},




		},

		onReachBottom: function(e) {
			if (this.total > this.dataList.length) {
				(this.queryParams.pageNum) ++;
				this.getList()
			}
		},
	}
</script>

<style lang="scss" scoped>
	page {
		background: #F9F9F9;
	}

	.btn {
		position: fixed;
		bottom: 0;
		left: 0;
		height: 118rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 0rpx 0rpx rgba(0, 0, 0, 0.06);
		padding-bottom: 68rpx;
		padding-left: 30upx;
		padding-right: 30upx;
		padding-top: 30upx;
		width: calc(100% - 60upx);

		.btn-item {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 30rpx;
			color: #111111;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.btn-plus {
			width: 56rpx;
			height: 56rpx;
			background: #E0F3EA;
			border-radius: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
			margin-right: 20upx;
		}

	}

	.main {
		padding: 0;
		padding-bottom: 260upx;
		padding-top: 0upx;
	}

	.list {
		padding: 0 24upx;
		width: calc(100% - 48upx);

		.item {
			margin-bottom: 20upx;
			width: calc(100% - 60upx);
			background: #FFFFFF;
			border-radius: 10upx;
			padding: 30upx;
			display: flex;
			justify-content: space-between;

			.item-img {
				width: 140upx;
				height: 140upx;
				border-radius: 6rpx;
				margin-right: 28upx;
			}


			.item-right {
				width: calc(100% - 28upx - 140upx);
				position: relative;

				.item-name {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
					border-bottom: 1rpx solid #E4E4E4;
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding-bottom: 12upx;
					margin-bottom: 14upx;
				}

				.item-name-left {
					display: flex;
					align-items: center;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
				}

				.item-name-tip {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
					margin-left: 10upx;
					margin-right: 20upx;
				}

				.item-single {
					display: flex;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
					margin-top: 10upx;
				}

				.item-single-name {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
					width: 120rpx;
					display: inline-block;
					margin-right: 12upx;

				}

				.item-single-value {
					display: inline-block;
					width: calc(100% - 120upx - 12upx);
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #111111;
				}




				.item-btn {
					width: 100rpx;
					height: 40rpx;
					background: #11AA66;
					border-radius: 4rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 40upx;
				}

				.item-btn-red {
					background: #F01022;
				}

				.item-btn-yellow {
					background: #FE9406;
				}
			}


		}

	}

	.tabs {
		// margin-top: 26upx;
		width: 100%;
		height: 106upx;
		display: flex;
		align-items: center;
		z-index: 3;
		position: relative;
		background: #FFFFFF;

		.tabs-item {
			height: 106upx;
			line-height: 106upx;
			text-align: center;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 30rpx;
			color: #999999;
			width: 50%;

		}

		.tabs-item-active {
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 32rpx;
			color: #11AA66;
			position: relative;
			z-index: 4;
		}

		.tabs-item-text {
			position: relative;
			z-index: 4;
		}

		.tabs-item-active::after {
			content: '';
			position: absolute;
			width: 60rpx;
			height: 8rpx;
			background: linear-gradient(180deg, #11AA66 0%, #12C66B 100%);
			bottom: 0upx;
			left: 50%;
			transform: translateX(-50%);
			z-index: 0;
		}

		.tabs-line {
			width: 2upx;
			height: 40upx;
			background: rgba(228, 228, 228, 1);
		}
	}
</style>